package com.vimi8.chick.plugins.manager;

import android.content.Context;
import android.text.TextUtils;

import com.eros.framework.constant.Constant;
import com.eros.framework.manager.Manager;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
import com.umeng.commonsdk.UMConfigure;
import com.umeng.socialize.PlatformConfig;
import com.umeng.socialize.UMShareAPI;
import com.vimi8.chick.plugins.model.ShareInitBean;
import com.vimi8.chick.plugins.model.WXApiModule;

import java.util.HashMap;

public class ShareManager extends Manager {

    @Override
    public void init() {
        super.init();
    }

    public void initShare(ShareInitBean bean, Context context) {
        UMConfigure.init(context, bean.getUmeng(), "umeng", UMConfigure.DEVICE_TYPE_PHONE, "");
        UMShareAPI.get(context);
        if (!TextUtils.isEmpty(bean.getWx())) {
            PlatformConfig.setWeixin(bean.getWx(), bean.getWxSecret());
            WXApiModule.getInstans().onCreateWXApi(context, bean.getWx());
        }
        if (!TextUtils.isEmpty(bean.getQq())) {
            PlatformConfig.setQQZone(bean.getQq(), bean.getQqSecret());
        }
        if (!TextUtils.isEmpty(bean.getWeibo())) {
            PlatformConfig.setSinaWeibo(bean.getWeibo(), bean.getWeiboSecret(), bean.getWeiboCallback());
        }
    }

    @Override
    public HashMap<String, HashMap<String, String>> getComponentsAndModules() {
        HashMap<String, HashMap<String, String>> result = new HashMap<>();

        HashMap<String, String> moudles = new HashMap<>();
        moudles.put("vmShare", "com.vimi8.chick.plugins.module.ShareModule");
        result.put(Constant.CUSTOMER_MODULES, moudles);

        return result;
    }
}
